// home组件vuex仓库
// search模块vuex仓库
import {reqCategoryList} from "../../api";

const state = {
  categoryList:[],  //state的默认数据为空数组，请求获取到了在赋值给（服务器返回的是数组，Satte初始值是空数组[],如果是返回对象就是空对象）
};
const mutations = {
  CATEGORYLIST(state,categoryList){
    state.categoryList = categoryList
  }
};
const actions = {
 async categoryList({commit}){
    // 通过api里面的接口函数调用-给发送请求获取数据
    let result =await reqCategoryList()
    console.log(result)
   if (result.code == 200){
     commit('CATEGORYLIST')
   }


  }
};
const getters = {};






export default {
  state,
  mutations,
  actions,
  getters,
}


